package com.yupi.maker.generator.file;

import freemarker.template.TemplateException;

import java.io.File;
import java.io.IOException;


/**
 *汇总静态和动态生成
 */
public class FileGenerator {



    public static void doGenerate(Object model) throws TemplateException, IOException {

        //这里就已经生成acm-template，只不过是个静态模板，里面的java文件锁挖的坑还没有填值
        String projectPath = System.getProperty("user.dir");
        File parentFile = new File(projectPath).getParentFile();
        String inputPath = new File(parentFile+ File.separator+"yuzi-generator-demo-projects"+ File.separator + "acm-template").getAbsolutePath();
        String outputPath = projectPath;
        StaticFileGenerator.copyFileByHutool(inputPath,outputPath);

        //给MainTemplate.java中的坑赋上动态的值
//        String dynamicinputPath = projectPath +File.separator+"yuzi-generator-maker"+File.separator+ "src/main/resources/templates/MainTemplate.java.ftl";
        String dynamicinputPath = projectPath +File.separator+ "src/main/resources/templates/MainTemplate.java.ftl";
//        String dynamicoutputPath = projectPath+ File.separator + "acm-template/src/com/yupi/acm/MainTemplate.java";
        String dynamicoutputPath = projectPath+ File.separator+"acm-template/src/com/yupi/acm/MainTemplate.java";
        DynamicFileGenerator.doGenerate(dynamicinputPath,dynamicoutputPath,model);
    }

    }

